﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Platform.Infrastructure;
using FastMember;

namespace Platform.ObjectModel
{
	/// <summary>
	/// Representa um documento de dados
	/// </summary>
	public class DocumentFlake : DataObjectFlake, IQualifiedDataObject
	{

		public DocumentFlake( DataObjectName schemaName )
			: this( null, schemaName )
		{ }

		public DocumentFlake( DocumentToken token, DataObjectName schemaName )
		{
			Arguments.IsNotNull( "schemaName", schemaName );

			this.Token = token;
			this.SchemaName = schemaName;
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="fieldName"></param>
		/// <returns></returns>
		public object this[ DataObjectName fieldName ]
		{
			get { return base[ this.SchemaName.FieldName( fieldName ) ]; }
			set { base[ this.SchemaName.FieldName( fieldName ) ] = value; }
		}


		/// <summary>
		/// Obtém ou define o token que identifica o documento
		/// </summary>
		public DocumentToken Token
		{ get; set; }

		/// <summary>
		/// Obtém o nome que identifica qual schema está sendo utilizado nesse documento
		/// </summary>
		public DataObjectName SchemaName
		{ get; internal protected set; }

		/// <summary>
		/// Obtém o nome que identifica qual schema está sendo utilizado nesse documento
		/// </summary>
		DataObjectName IQualifiedDataObject.QualifiedName
		{ get { return this.SchemaName; } }
	}


	//internal interface IDocumentFlake : IQualifiedDataObject
	//{

	//    //DocumentToken Token
	//    //{ get; }

	//    //object this[ DataObjectName fieldName ]
	//    //{ get; set; }
	//}
}
